package com.exam.serviceimpl;

import com.exam.entity.Admin;
import com.exam.entity.Login;
import com.exam.entity.Student;
import com.exam.entity.Teacher;
import com.exam.mapper.LoginMapper;
import com.exam.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private LoginMapper loginMapper;
    @Override
    public Admin adminLogin(Login login) {
        Admin admin = new Admin();
        admin.setAdminId(login.getUsername());
        admin.setPwd(login.getPassword());
        return loginMapper.adminLogin(admin);
    }
    @Override
    public Teacher teacherLogin(Login login) {
        Teacher teacher = new Teacher();
        teacher.setTeacherId(login.getUsername());
        teacher.setPwd(login.getPassword());
        return loginMapper.teacherLogin(teacher);
    }
    @Override
    public Student studentLogin(Login login) {
        Student student = new Student();
        student.setStudentId(login.getUsername());
        student.setPwd(login.getPassword());
        return loginMapper.studentLogin(student);
    }
    @Override
    public int studentRegister(Login login) {
        Student student = new Student();
        student.setStudentId(login.getUsername());
        student.setPwd(login.getPassword());
        return loginMapper.studentRegister(student);
    }
}
